# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=zackattack
pkgver=5.1f96c14
pkgrel=11
pkgdesc='A new tool set to do NTLM Authentication relaying unlike any other tool currently out there.'
groups=('blackarch' 'blackarch-networking' 'blackarch-scanner'
        'blackarch-cracker')
arch=('any')
url='https://github.com/urbanesec/ZackAttack/'
license=('custom:unknown')
depends=('ruby' 'ruby-sqlite3' 'ruby-webrick')
makedepends=('git')
source=("$pkgname::git+https://github.com/urbanesec/ZackAttack.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  sed -i "s|'sqlite3', '1.3.6'|'sqlite3'|g" lib/zfdb.rb
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm *.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ruby $pkgname.rb "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

